home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDXPCH / CHECK.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  6.8 KB  |  222 lines

  1. ;+
  2. ;  CHECK.S - check for existence of different components in system.
  3. ;-
  4.  
  5. .include    "defs.h"
  6. .include    "68030.s"
  7.  
  8. REGBASE    equ    1            ; most are on odd part of data bus
  9. bSCSI    equ    $FFFF8780+REGBASE    ; base address of SCSI bus
  10. bAT    equ    $FFF00000+REGBASE    ; base address of AT bus
  11. WDC    equ    $FFFF8604        ; base address of ACSI bus
  12.  
  13. ;+
  14. ; chksp:() - Check if running on a Sparrow
  15. ;
  16. ; Uses: d0, d1
  17. ;-
  18.     .extern    _getcookie
  19.     .globl    _chksp
  20. _chksp:    movem.l    d1/a0-a1,-(sp)
  21.     move.l    #machine,-(sp)        ; ptr to machine type
  22.     move.l    #_MCH,-(sp)        ; looking for _MCH cookie
  23.     bsr    _getcookie
  24.     addq.w    #8,sp            ; clean up stack
  25.     moveq    #0,d0            ; assume we are NOT on a Sparrow
  26.     cmpi.l    #SPARROW,machine    ; are we?
  27.     bne.s    spdone            ; if not, fine
  28.     moveq    #1,d0            ; else, there is Sparrow SCSI
  29. spdone:    movem.l    (sp)+,d1/a0-a1
  30.     rts
  31.  
  32.  
  33.  
  34. ;+
  35. ; chkscsi() - Check if SCSI bus exists
  36. ;
  37. ; Uses: d0, d1, d2, a0, a1
  38. ;-
  39.  
  40.     .globl    _chkscsi
  41. _chkscsi:                ; check if SCSI exists
  42.     move.l    #0,savssp        ; no stack pointer is saved yet
  43.     move.l    #1,-(sp)        ; find out what mode processor is in
  44.     move.w    #$20,-(sp)        ; Super(1L)
  45.     trap    #1
  46.     addq.w    #6,sp            ; clean up stack
  47.     tst.w    d0            ; in Supervisor mode already?
  48.     bne.s    tscsi            ; if so, go test for SCSI
  49.     clr.l    -(sp)            ; else go to Supervisor mode
  50.     move.w    #$20,-(sp)        ; Super(0L)
  51.     trap    #1
  52.     addq.w    #6,sp            ; clean up stack
  53.     move.l    d0,savssp        ; save original stack pointer
  54. tscsi:    clr.w    result            ; assume SCSI doesn't exist
  55.     movea.l    BERR,a0            ; save original bus error vector
  56.     move.l    #nbus,BERR        ; install our own vector
  57.     movea.l    sp,a1            ; save current stack pointer
  58.     move.b    bSCSI,d1        ; try to access the SCSI bus
  59.     move.w    #1,result        ; if no bus error, SCSI exists
  60. nbus:    move.l    a0,BERR            ; restore original bus error vector
  61.     move.l    a1,sp            ; restore stack pointer
  62. chkret:    tst.l    savssp            ; were we in User mode when started?
  63.     beq.s    tend            ; if not, just return
  64.     move.l    savssp,-(sp)        ; go back to User mode 
  65.     move.w    #$20,-(sp)        ; Super(savssp)
  66.     trap    #1
  67.     addq.w    #6,sp            ; clean up stack
  68. tend:    move.w    result,d0        ; d0 = result
  69.     rts
  70.  
  71.  
  72. ;+
  73. ; chkacsi() - Check if ACSI bus exists
  74. ;
  75. ; Uses: d0, d1, d2, a0, a1
  76. ;-
  77.     .globl    _chkacsi
  78. _chkacsi:                ; check if SCSI exists
  79.     move.l    #0,savssp        ; no stack pointer is saved yet
  80.     move.l    #1,-(sp)        ; find out what mode processor is in
  81.     move.w    #$20,-(sp)        ; Super(1L)
  82.     trap    #1
  83.     addq.w    #6,sp            ; clean up stack
  84.     tst.w    d0            ; in Supervisor mode already?
  85.     bne.s    tacsi            ; if so, go test for SCSI
  86.     clr.l    -(sp)            ; else go to Supervisor mode
  87.     move.w    #$20,-(sp)        ; Super(0L)
  88.     trap    #1
  89.     addq.w    #6,sp            ; clean up stack
  90.     move.l    d0,savssp        ; save original stack pointer
  91. tacsi:    clr.w    result            ; assume SCSI doesn't exist
  92.     movea.l    BERR,a0            ; save original bus error vector
  93.     move.l    #nbus,BERR        ; install our own vector
  94.     movea.l    sp,a1            ; save current stack pointer
  95.     move.w    WDC,d1            ; try to access the ACSI bus
  96.     move.w    #1,result        ; if no bus error, ACSI exists
  97.     bra    nbus
  98.  
  99.  
  100. ;+
  101. ; chkide() - Check if IDE bus exists
  102. ;
  103. ; Uses: d0, d1, d2, a0, a1
  104. ;-
  105.     .globl    _chkide
  106. _chkide:                    ; check if AT bus exists
  107.     move.l    #0,savssp        ; no stack pointer is saved yet
  108.     move.l    #1,-(sp)        ; find out what mode processor is in
  109.     move.w    #$20,-(sp)        ; Super(1L)
  110.     trap    #1
  111.     addq.w    #6,sp            ; clean up stack
  112.     tst.w    d0            ; in Supervisor mode already?
  113.     bne.s    tide            ; if so, go test for AT
  114.     clr.l    -(sp)            ; else go to Supervisor mode
  115.     move.w    #$20,-(sp)        ; Super(0L)
  116.     trap    #1
  117.     addq.w    #6,sp            ; clean up stack
  118.     move.l    d0,savssp        ; save original stack pointer
  119. tide:    clr.w    result            ; assume AT bus doesn't exist
  120.     movea.l    BERR,a0            ; save original bus error vector
  121.     move.l    #nbus,BERR        ; install our own vector
  122.     movea.l    sp,a1            ; save current stack pointer
  123.     move.b    bAT,d1            ; try to access the AT bus
  124.     move.w    #1,result        ; if no bus error, AT exists
  125.     bra    nbus
  126.  
  127.  
  128. ;+
  129. ; chkblit() - Check if BLiTTER exists
  130. ;
  131. ; Uses: d0
  132. ;-
  133.     .globl    _chkblit
  134. _chkblit:
  135.     move.w    #-1,-(sp)
  136.     move.w    #64,-(sp)        ; blitmode(-1)
  137.     trap    #14
  138.     addq.w    #4,sp            ; clean up stack
  139.     btst    #1,d0            ; does BLiTTER exist?
  140.     beq.s    nblit
  141.     moveq    #1,d0            ; return 1 if exists
  142.     rts
  143. nblit:    moveq    #0,d0            ; return 0 if not
  144.     rts
  145.  
  146.  
  147. ;+
  148. ; chkcache() - Check if '030 cache exists
  149. ;
  150. ; Uses: d0, d1, d2, a0, a1
  151. ;-
  152.     .globl    _chkcache
  153. _chkcache:                ; check if '030 cache exists
  154.     move.l    #0,savssp        ; no stack pointer is saved yet
  155.     move.l    #1,-(sp)        ; find out what mode processor is in
  156.     move.w    #$20,-(sp)        ; Super(1L)
  157.     trap    #1
  158.     addq.w    #6,sp            ; clean up stack
  159.     tst.w    d0            ; in Supervisor mode already?
  160.     bne.s    tcache            ; if so, go test for cache
  161.     clr.l    -(sp)            ; else go to Supervisor mode
  162.     move.w    #$20,-(sp)        ; Super(0L)
  163.     trap    #1
  164.     addq.w    #6,sp            ; clean up stack
  165.     move.l    d0,savssp        ; save original stack pointer
  166. tcache:    clr.w    result            ; assume cache doesn't exist
  167.     movea.l    IINS,a0            ; save orig illegal instrn vector
  168.     move.l    #ncache,IINS        ; install our own vector
  169.     movea.l    sp,a1            ; save current stack pointer
  170.     movecacrd0            ; does a cache exist?
  171.     move.w    #1,result        ; if so, set result
  172. ncache:    move.l    a0,IINS            ; restore orig illegal instrn vector
  173.     move.l    a1,sp            ; restore stack pointer
  174.     bra    chkret
  175.  
  176.  
  177. ;+
  178. ; _Stbook() - to find out if driver is being run on the ST Book.
  179. ;
  180. ; Comments:
  181. ;    On the ST Book, the palette registers are only readable.
  182. ; So, to determine if the driver is being run on the ST Book, write
  183. ; to the palette registers, and then read them back.  If what read
  184. ; back isn't the same as what's been written, it IS an ST Book.
  185. ; The palette starts at address $ffff8240.
  186. ;-
  187.     .globl  _stbook
  188. _stbook:
  189.     move.l    #0,savssp        ; no stack pointer is saved yet
  190.     move.l    #1,-(sp)        ; find out what mode processor is in
  191.     move.w    #$20,-(sp)        ; Super(1L)
  192.     trap    #1
  193.     addq.w    #6,sp            ; clean up stack
  194.     tst.w    d0            ; in Supervisor mode already?
  195.     bne.s    tbook            ; if so, go test if it's STBook
  196.     clr.l    -(sp)            ; else go to Supervisor mode
  197.     move.w    #$20,-(sp)        ; Super(0L)
  198.     trap    #1
  199.     addq.w    #6,sp            ; clean up stack
  200.     move.l    d0,savssp        ; save original stack pointer
  201. tbook:    move.l  $ffff8242,d2        ; save palette registers old values
  202.     move.w  #$0555,$ffff8242    ; write new pattern to 1st register
  203.     move.w  #$0222,$ffff8244    ; write new pattern to 2nd register
  204.     move.w  #1,result        ; assume it IS an ST Book
  205.     move.w  $ffff8242,d1        ; read from 1st palette register
  206.     and.w   #$0777,d1        ; mask out useless bits
  207.     cmp.w   #$0555,d1        ; value stays the same?
  208.     bne.s   .0            ; if not, it IS an ST Book
  209.     move.w  $ffff8244,d1        ; read from 2nd palette register
  210.     and.w   #$0777,d1        ; mask out useless bits
  211.     cmp.w   #$0222,d1        ; value stays the same?
  212.     bne.s   .0            ; if not, it IS an ST Book
  213.     move.w  #0,result        ; else, it is NOT an ST Book
  214.     move.l  d2,$ffff8242        ; restore palette registers
  215. .0:    bra    chkret    
  216.  
  217.  
  218. .bss
  219. savssp:        ds.l    1            ; stack pointer
  220. result:        ds.w    1
  221. machine:    ds.l    1
  222.